
#include "Common.h"
#include "memory"

#include "Intaddr.h"
#include "Listen.h"
#include "Reactor.h"

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "使用方式错误,正确调用方式: " << argv[0] << " port" << std::endl;
        exit(Err_Use);
    }
    zmh::Intaddr addr(AF_INET, std::stoi(argv[1]));

    // 构建listen对象
    std::unique_ptr<zmh::Connection> listen = std::make_unique<zmh::Listen>(addr);

    // 创建Reactor
    std::unique_ptr<zmh::Reactor> R = std::make_unique<zmh::Reactor>();
    R->AddConnection(std::move(listen));
    R->Loop();

    return 0;
}